<template>
  <div>
    <div class="header">
      <van-icon
        class="back-btn"
        name="arrow-left"
        @click="$router.push('/order/tea')"
      />
      <div class="title">订单详情</div>
    </div>
    <div class="content">
      <img src="./images/logo.png" class="logo" />
      <div class="card">
        <div class="order-status">订单已完成</div>
        <span>感谢您对茶百道的支持，期待您的再次光临</span>
        <div class="buy-btn" @click="$router.push('/buy')">再来一单</div>
      </div>
      <div class="card2">
        <div class="code">
          <span>订单号：</span>
          <span>{{ order_code }}</span>
        </div>
        <ul class="order-list">
          <li v-for="(item, index) in orderList" :key="index">
            <div class="goods-pic">
              <img :src="item.goods_img" />
            </div>
            <div class="goods-info">
              <div class="goods-nane">{{ item.goods_name }}</div>
              <div class="goods-choose">{{ item.goods_choose }}</div>
            </div>
            <div class="goods-num">
              <div class="price"><span>¥</span>{{ item.goods_price }}</div>
              <div class="num">x{{ item.goods_num }}</div>
            </div>
          </li>
        </ul>
        <div class="order-info">
          共计 {{ num }} 件商品，合计 <span><i>¥</i>{{ total }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      order_code: "",
      orderList: [],
      total: "",
      num: "",
    };
  },
  created() {
    this.getOrderInfo();
  },
  methods: {
    getOrderInfo() {
      const { orderCode, goodsInfo, total, num } = this.$route.params.orderItem;
      this.order_code = orderCode;
      this.orderList = goodsInfo;
      this.total = total;
      this.num = num;
    },
  },
};
</script>

<style lang="less" scoped>
.header {
  width: 100%;
  height: 50px;
  background-color: #fff;
  position: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  .back-btn {
    position: absolute;
    left: 10px;
    font-size: 18px;
  }
}
.content {
  padding: 100px 10px 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  .logo {
    width: 120px;
    height: 120px;
  }
  .card {
    width: 100%;
    height: 190px;
    background-color: #fff;
    border-radius: 15px;
    padding: 20px 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    margin-bottom: 10px;
    box-shadow: 0 0 3px rgb(0 0 0 / 10%);
    .order-status {
      font-size: 18px;
      font-weight: 600;
    }
    span {
      font-size: 14px;
      margin: 20px 0 30px;
    }
    .buy-btn {
      width: 85px;
      height: 30px;
      color: #143ea9;
      font-size: 13px;
      border: 1px solid #143ea9;
      border-radius: 15px;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
  .card2 {
    width: 100%;
    // min-height: 220px;
    // max-height: 290px;
    background-color: #fff;
    border-radius: 15px;
    margin-bottom: 10px;
    box-shadow: 0 0 3px rgb(0 0 0 / 10%);
    padding: 15px 10px;
    box-sizing: border-box;
    .code {
      margin-bottom: 10px;
      font-size: 13px;
      color: #969799;
    }
    .order-list {
      // max-height: 140px;
      border-top: 1px solid #ebedf0;
      border-bottom: 1px solid #ebedf0;
      padding: 10px 0;
      box-sizing: border-box;
      li {
        width: 100%;
        height: 70px;
        background-color: #fff;
        display: flex;
        align-items: center;
        .goods-pic {
          height: 60px;
          width: 60px;
          text-align: center;
          img {
            height: 100%;
          }
        }
        .goods-info {
          align-self: flex-start;
          margin-left: 10px;
          .goods-nane {
            margin-bottom: 10px;
            font-size: 15px;
          }
          .goods-choose {
            font-size: 13px;
            color: #969799;
          }
        }
        .goods-num {
          align-self: flex-start;
          margin-left: auto;
          justify-content: flex-end;
          .price {
            margin-bottom: 10px;
            font-size: 15px;
            span {
              font-size: 13px;
            }
          }
          .num {
            font-size: 13px;
            color: #969799;
            display: flex;
            justify-content: end;
          }
        }
      }
    }
    .order-info {
      height: 30px;
      display: flex;
      justify-content: flex-end;
      align-items: flex-end;
      font-size: 13px;
      color: #969799;
      span {
        font-size: 16px;
        color: #333;
        margin-left: 5px;
        i {
          font-size: 13px;
        }
      }
    }
  }
}
</style>